var mongoose=require('mongoose');
var Post=mongoose.model('Post',{
    title:String,
    author:String,
    read:{//阅读次数
        type:Number,
        default:0
    },
    comments:[{
        content:String,
        like:{//赞
            type:Number,
            default:0
        }
    }]
});
mongoose.connect('mongodb://localhost/MongoDB_QuanWei_2');


Post.findOneAndUpdate({title:'post 1'},{},(err,r)=>{
    console.log(err,r);

    Post.update({title:'post 1'},{$inc:{read:10}},(err,r)=>{
        console.log(err,r);

    });

});
/*
* $inc:{field:val}
* 字段值加上val
* val必须为整数或双精度浮点数
* */